<?php
/**
 * Created by PhpStorm.
 * User: rain
 * Date: 2018/4/5
 * Time: 下午4:51
 */

namespace App\Http\Controllers\Api;


use App\Models\UserSign;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;


class SignController extends AuthorizedController
{
    public function create(Request $request)
    {
        $user = $request->apiUser;
        UserSign::firstOrCreate([
            'user_id' => $user->id,
            'year_month' => date('Ym'),
            'date' => date('Y-m-d'),
        ]);

        return $this->success();
    }

    public function list(Request $request)
    {
        $user = $request->apiUser;

        $list = UserSign::where([
            'user_id' => $user->id,
            'year_month' => $request->get('year', date('Y')) . $request->get('month', date('m')),
        ])->pluck('date');

        return $this->success(['list' => $list]);

    }


}
